package com.hero.web.controller.system;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author By ZengPeng
 * @Description 用于测试
 * @date in  2020/8/19 9:35
 * @Modified By
 */
@RestController
@RequestMapping("/polling")
public class TestPollingController {
    private static final String[] station;

    static {
        station = new String[]{"[{\n" +
                "\t\t\"lineNo\": \"1\",\n" +
                "\t\t\"sortId\": \"1-01\",\n" +
                "\t\t\"focused\": false,\n" +
                "\t\t\"lineId\": 1,\n" +
                "\t\t\"lineName\": \"1号线\",\n" +
                "\t\t\"stationName\": \"西塱\",\n" +
                "\t\t\"stationId\": 1\n" +
                "\t},\n" +
                "\t{\n" +
                "\t\t\"lineNo\": \"1\",\n" +
                "\t\t\"sortId\": \"1-02\",\n" +
                "\t\t\"focused\": false,\n" +
                "\t\t\"lineId\": 1,\n" +
                "\t\t\"lineName\": \"1号线\",\n" +
                "\t\t\"stationName\": \"坑口\",\n" +
                "\t\t\"stationId\": 2\n" +
                "\t}","{\n" +
                "\t\t\"lineNo\": \"2\",\n" +
                "\t\t\"sortId\": \"2-20\",\n" +
                "\t\t\"focused\": false,\n" +
                "\t\t\"lineId\": 2,\n" +
                "\t\t\"lineName\": \"2号线\",\n" +
                "\t\t\"stationName\": \"白云文化广场\",\n" +
                "\t\t\"stationId\": 36\n" +
                "\t},\n" +
                "\t{\n" +
                "\t\t\"lineNo\": \"2\",\n" +
                "\t\t\"sortId\": \"2-21\",\n" +
                "\t\t\"focused\": false,\n" +
                "\t\t\"lineId\": 2,\n" +
                "\t\t\"lineName\": \"2号线\",\n" +
                "\t\t\"stationName\": \"萧岗\",\n" +
                "\t\t\"stationId\": 37\n" +
                "\t}"};
    }

    @GetMapping("/lineStation")
    public Object lineStation(@RequestParam( required = false) Integer lineId)
    {
        if(lineId ==null)
            return station;

        if(lineId>station.length-1)
            return "未找到数据";

        return station[lineId];
    }
}
